package com.relax.controller;

import com.relax.entity.Order;
import com.relax.mapper.OrderMapper;
import com.relax.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private OrderMapper orderMapper;

    @PostMapping("create")
    public Order create(Integer userId) {
        Order order = new Order();
        order.setOrderNo(System.currentTimeMillis() + "");
        order.setId(userId);
        System.out.println("返回数据"+order.toString());
        return order;
    }


    @PostMapping("updateForSeata")
    void updateForSeata(@RequestParam("id") Integer id) {
        System.out.println("order 服务的updateForSeata方法被调用");
        Integer integer = orderMapper.updateForSeata(id, System.currentTimeMillis() + "");
    }
}
